package com.bawei.mall.product.controller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.domain.reponse.ProductGoodsResponse;
import com.bawei.mall.product.domain.request.GenerateOrderRequest;
import com.bawei.mall.product.service.MallProductGoodsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：韩丹阳
 * @Package：com.bawei.mall.product.controller
 * @Project：mall_cloud
 * @name：MallProductGoodsInfoController
 * @Date：2024/7/9 上午 11:56
 */
@RestController
@RequestMapping("/goods")
public class MallProductGoodsInfoController {

    @Autowired
    private MallProductGoodsInfoService mallProductGoodsInfoService;

    /**
     * 订单详情预览
     * @param ids
     * @return
     */
    @PostMapping("/generateConfirmOrder")
    public R<ProductGoodsResponse> generateConfirmOrder(@RequestBody Integer[] ids) {
        ProductGoodsResponse productGoodsResponse = mallProductGoodsInfoService.generateConfirmOrder(ids);
        return R.ok(productGoodsResponse);
    }

    /**
     * 生成订单
     * @param generateOrderRequest
     * @return
     */
    @PostMapping("/generateOrder")
    public R generateOrder(@RequestBody GenerateOrderRequest generateOrderRequest) {
        mallProductGoodsInfoService.generateOrder(generateOrderRequest);
        return R.ok();
    }


}
